import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { Rate } from 'antd-v4';
import React from 'react';
/**
 * 评分组件
 *
 * @param
 */

var FieldRate = function FieldRate(_ref, ref) {
  var text = _ref.text,
      mode = _ref.mode,
      render = _ref.render,
      renderFormItem = _ref.renderFormItem,
      fieldProps = _ref.fieldProps;

  if (mode === 'read') {
    var dom = _jsx(Rate, _objectSpread(_objectSpread({
      allowHalf: true,
      disabled: true,
      ref: ref
    }, fieldProps), {}, {
      value: text
    }));

    if (render) {
      return render(text, _objectSpread({
        mode: mode
      }, fieldProps), _jsx(_Fragment, {
        children: dom
      }));
    }

    return dom;
  }

  if (mode === 'edit' || mode === 'update') {
    var _dom = _jsx(Rate, _objectSpread({
      allowHalf: true,
      ref: ref
    }, fieldProps));

    if (renderFormItem) {
      return renderFormItem(text, _objectSpread({
        mode: mode
      }, fieldProps), _dom);
    }

    return _dom;
  }

  return null;
};

export default /*#__PURE__*/React.forwardRef(FieldRate);